<%--
  Created by IntelliJ IDEA.
  User: 13585
  Date: 2020/12/23
  Time: 8:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="top.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>我的信息</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/index.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="js/jquery-3.2.1.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<div id="update">
    <div class="title">修改密码</div>
    <c:if test="${!empty msg}">
        <div id="prompt">
            <span>${msg}</span>
            <button onclick="changeDis()" class="btn btn-primary">确定</button>
        </div>
    </c:if>
    <script>
        function changeDis() {
            let msg = document.getElementById("prompt");
            msg.style.display = "none";
        }
    </script>
    <div class="content">
        <form class="form-horizontal" action="modifyPassword" onsubmit="return checkReg()">
            <input type="text" name="id" style="display: none" value="${sessionScope.user.id}">
            <div class="form-group">
                <label for="inputpass" class="col-sm-3 control-label">原密码:</label>
                <div class="col-sm-5">
                    <input type="text" name="oldpass" class="form-control" id="inputpass" placeholder="旧密码">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword1" class="col-sm-3 control-label">新密码:</label>
                <div class="col-sm-5">
                    <input type="password" name="newpass" class="form-control" id="inputPassword1" placeholder="新密码">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword2" class="col-sm-3 control-label">确认新密码:</label>
                <div class="col-sm-5">
                    <input type="password" class="form-control" id="inputPassword2" placeholder="新密码">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-5">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    function checkReg() {
        let firstpassword = document.getElementById("inputPassword1").value;
        let lastpassword = document.getElementById("inputPassword2").value;
        if(firstpassword != lastpassword ){
            alert("两次密码不一样");
            return false;
        }else {
            return true;
        }
    }
</script>
</body>
</html>
